
from urllib.parse import urlencode
import scrapy


class A工作状态Spider(scrapy.Spider):
    name = "工作状态"

    async def start(self):
        cookies = {
            'Path': '/',
            '4hP44ZykCTt5O': '60Pe8bTsfUOP7X.eiV7sRycTUcYYsEPXG5DmXKMj5vvCALhri0EX41j7yRQFPuc3jGe048qw7_qPLsULT57fEUpG',
            '7d0f4f97e8317b129e': '3601cf1eb5196db6546ba2733010c134',
            '_gscu_984081904': '63119523nghmf618',
            '_gscbrs_984081904': '1',
            'yfx_c_g_u_id_10000005': '_ck25111419252518517537673902612',
            'yfx_f_l_v_t_10000005': 'f_t_1763119525846__r_t_1763119525846__v_t_1763119525846__r_c_0',
            '4hP44ZykCTt5P': '0jDGAO2uQ4vAV6Nvqk80APZ7uAbx2tKbUsHQcKovP3DWrLDoudoVYUtN2vvVc5cVbVPJmETfY2j5Un0U.ffPPm7mkRet6Dktx.zpaGhcvMoAtfaRDvBtF7.LwzPVD6ZhMZFvoyuyVyBzMT8Ft7BkbY0I90fxobi0fMkmtW5cYwtJ0qxbvlEiahMZAQhonOhrxB1KPVcIUzI5gConxFXMwnFX8addyIbEOl3TNr9jchmpmFux8eVmvYBSGtNjoD8YQd9LgtxmoU2NQ4uo4fP5HzYO1as5X0rHjeg7esC.IYNl7OeaIsTiHV4d_IpS.nEi6flC5xihMYvDjdsTdJsyMmlEyy.DDiGAyVlay2GzVolOYQraG9.lFv7EMmuCiKONsgRkbXObTkXXNZ2.GJmu13YQqQrKXz6rDCqJURGr2Z7bh3lwF7WHu8Vp0kgo0m378',
        }



        headers = {
            'Accept': '*/*',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Pragma': 'no-cache',
            'Referer': 'https://wsb.gansu.gov.cn/wsb/c116314/list.shtml',
            'Sec-Fetch-Dest': 'empty',
            'Sec-Fetch-Mode': 'cors',
            'Sec-Fetch-Site': 'same-origin',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'sec-ch-ua': '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
            'sec-ch-ua-mobile': '?0',
            'sec-ch-ua-platform': '"Windows"',
            # 'Cookie': 'Path=/; 4hP44ZykCTt5O=60Pe8bTsfUOP7X.eiV7sRycTUcYYsEPXG5DmXKMj5vvCALhri0EX41j7yRQFPuc3jGe048qw7_qPLsULT57fEUpG; 7d0f4f97e8317b129e=3601cf1eb5196db6546ba2733010c134; _gscu_984081904=63119523nghmf618; _gscbrs_984081904=1; yfx_c_g_u_id_10000005=_ck25111419252518517537673902612; yfx_f_l_v_t_10000005=f_t_1763119525846__r_t_1763119525846__v_t_1763119525846__r_c_0; _gscs_984081904=63119523dngceo18|pv:4; 4hP44ZykCTt5P=0v9jlEa0_HAxFLs5sYtvKr7pMBWFQuf1Sdkd9qVkZJmnaoG_T8mSSXO5jw6XivtsUudpm6DXIUS6UztmDa11bEu8D5.BZxxzoxk2ylgyQJXMuU4VGntp6BdP._h1d6OgZ1LebKteLuzdo75f5imy84uwP6ozRaNF9h7whiCQHGvdLfaOGH7Mjzuym6sSx8laAC66FQojnc2ZZHIg6qCTAq7QQMgMvbXigsdsPo32LMZS7O8ZIO25Q3GUJ7BE6iGPo0u8YqJwbPYw7Q855FJU7z.HEjIEVZKo7kNt3Q8AOYRgU47LO.3zw.M9oTvGNa3ncm5XU3OzYOFbHakjJvpRNcxPTg1pB8S2ImDwtFOFLP8g82kZfZ63G3t6tJ6kq8s3ND38PmQLzJRSBrN81597jObOeSjwsBgFvmVJ5_DaVZ479mb94qDVJYUc.OynlA63V',
        }
        base_url = "https://wsb.gansu.gov.cn/common/search/ecdbf8efb0524164b80d5eeb00aa8348"
        params = {
            "_isAgg": "true",
            "_isJson": "true",
            "_pageSize": "20",
            "_template": "index",
            "_rangeTimeGte": "",
            "_channelName": "",
            "page": "2"  # 改这里翻页
        }
        url = f'{base_url}?{urlencode(params)}'
        print(url)
        yield scrapy.Request(url,headers=headers,cookies=cookies)


    def parse(self, response):
        print(response.url)
